import com.haojin.mybatis.mapper.DeptMapper;
import com.haojin.mybatis.pojo.Dept;
import com.haojin.mybatis.pojo.SqlSessionUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

/**
 * @author .29.
 * @create 2023-03-13 15:55
 */
public class testDeptMapper {
    @Test
    public void testGetDeptAndEmp(){
        SqlSession sqlSession = SqlSessionUtils.getSqlSession();
        DeptMapper mapper = sqlSession.getMapper(DeptMapper.class);
        Dept deptAndEmp = mapper.getDeptAndEmp(1);
        System.out.println(deptAndEmp);
    }

    @Test
    public void testGetDeptAndEmpByStep(){//分步查询，延迟加载效果
        SqlSession sqlSession = SqlSessionUtils.getSqlSession();
        DeptMapper mapper = sqlSession.getMapper(DeptMapper.class);
        Dept deptAndEmp = mapper.getDeptAndEmpByStep1(1);
        System.out.println(deptAndEmp.getDeptName());
        System.out.println("++++++++++++++++++++++++++++");
        System.out.println(deptAndEmp.getEmps());
    }
}
